<template>
  <div style="width: 100%; height: 100%; padding: 0 10px">
    <div class="jjb_text">{{ "监狱每日要情" }}&nbsp;</div>
    <div class="drawer_box">
      <div class="date_searchbox">
        <div>
          <el-date-picker
            style="width: 218px"
            v-model="value3"
            type="month"
            value-format="YYYY-MM"
            placeholder="选择年份"
            @change="chanse"
          />
        </div>

        <!-- <div class="btn_box" style="width: 100%">
          <div
            @click="btnClick(item, index)"
            :class="{ isAtv: isIndex == index }"
            class="itemz flex_center_center"
            v-for="(item, index) in jqArrCv"
            :key="index"
          >
            {{ item.name }}
          </div>
        </div> -->

        <div class="month_box">
          <div
            @click="itemClick(index, item)"
            class="items flex_center_center"
            v-for="(item, index) in dateArr"
            :key="index"
            :class="{ isDate: item.is }"
          >
            {{ item.date }}
          </div>
        </div>
      </div>
      <div style="height: 98%; width: 1360px; overflow-y: scroll">
        <el-form
          ref="ruleFormRef"
          :model="formDataJJB"
          label-position="right"
          v-if="isShows"
          label-width="140px"
        >
          <div class="date_box" style="margin-bottom: 10px">
            <!-- <div>
                值班日期：{{ isStartDate }} &nbsp;至&nbsp;
                {{ isEndDate }}
              </div>
              <div>填报人：{{ tbObj.reportUser }}</div> -->
          </div>
          <div class="jjb border_table" style="border-bottom: none">
            <el-table
              :span-method="objectSpanMethod"
              border
              :data="tableDataZb"
              style="width: 100%"
              @cell-click="zbCellClick"
            >
              <el-table-column prop="date" label="" width="160" align="center">
                <template #default="scope"> </template>
              </el-table-column>
              <!-- <el-table-column prop="name" label="" width="80" align="center" /> -->
              <el-table-column prop="a" label="" align="center" />
              <el-table-column
                prop="names"
                label=""
                width="80"
                align="center"
              />
              <el-table-column prop="b" label="" align="center" />
              <el-table-column prop="c" label="" width="90" align="center" />
              <el-table-column prop="d" label="" width="120" align="center" />
            </el-table>
          </div>
          <div
            class="jj_box"
            style="display: flex; width: 100%; justify-content: space-between"
          ></div>
          <div
            class="jjb border_table"
            style="border-bottom: none; border-top: none"
          >
            <!-- 狱情信息 -->
            <el-table
              border
              @cell-click="yqCellClick"
              :span-method="objectSpanMethodCv"
              :data="yqList"
              style="width: 100%"
            >
              <el-table-column
                prop="title"
                label=""
                width="100"
                align="center"
              />

              <el-table-column prop="content" label="情况描述">
                <template #default="scope">
                  <div class="colmm_table">
                    <div class="table_top">
                      <div style="width: 131px">在册</div>
                      <div style="width: 122px">在押</div>
                      <div style="width: 122px">实押</div>
                      <div style="width: 122px">监内住院</div>
                      <div style="width: 122px">离监探亲</div>
                      <div style="width: 122px">禁闭</div>
                      <div style="">惩戒训导</div>
                      <div style="">监外住院</div>
                      <div style="">监外执行</div>
                      <div style="border-right: none">历年在逃</div>
                    </div>
                    <el-table
                      border
                      :data="tableDatas"
                      style="
                        width: 100%;
                        border-left: 1px solid rgb(5, 112, 146);
                      "
                    >
                      <el-table-column prop="name" label="在册" align="center">
                        <template #default="scope">
                          {{ scope.row.zcfr }}
                        </template>
                      </el-table-column>
                      <el-table-column prop="zy" label="在押" align="center">
                        <template #default="scope">
                          {{ scope.row.zyfr }}
                        </template>
                      </el-table-column>
                      <el-table-column prop="syfr" label="实押" align="center">
                      </el-table-column>

                      <el-table-column
                        align="center"
                        prop="jnzy"
                        label="监内住院"
                      />
                      <el-table-column
                        align="center"
                        prop="ljtq"
                        label="离监探亲"
                      />
                      <el-table-column
                        align="center"
                        prop="jbfr"
                        label="禁闭"
                      />
                      <el-table-column
                        align="center"
                        prop="cjxd"
                        label="惩戒训导"
                      />
                      <el-table-column
                        align="center"
                        prop="jwzy"
                        label="监外住院"
                      />
                      <el-table-column
                        align="center"
                        prop="jwzx"
                        label="监外执行"
                      />
                      <el-table-column
                        align="center"
                        prop="tpfr"
                        label="历年在逃"
                      >
                      </el-table-column>
                    </el-table>
                  </div>
                </template>
              </el-table-column>
            </el-table>
          </div>
          <div
            class="jjb border_table"
            style="border-bottom: none; border-top: none"
          >
            <!-- 重要犯情 -->
            <el-table
              @cell-click="zyCellClick"
              :span-method="objectSpanMethod5"
              border
              :data="zdryTable"
              style="width: 100%"
            >
              <el-table-column
                prop="title"
                label=""
                width="100"
                align="center"
              />
              <el-table-column
                prop="type"
                width="120"
                label="情况描述"
                align="center"
              >
                <template #default="scope">
                  <div>
                    {{ scope.row.type }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column prop="content" label="情况描述">
                <template #default="scope">
                  <div>
                    {{ scope.row.content }}
                    <!-- <div
                      class="flex_start_start"
                      v-for="(item, index) in zdzfTabel"
                      :key="index"
                    >
                      <div style="margin-right: 20px">
                        {{
                          item.startDate.split("T")[0] +
                          " " +
                          item.startDate.split("T")[1]
                        }}
                      </div>
                      <div style="margin-right: 20px">{{ item.typeName }}</div>
                      <div>{{ item.name }}</div>
                    </div> -->
                  </div>
                </template>
              </el-table-column>
            </el-table>
          </div>
          <!-- 五安全一稳定 -->
          <div
            class="jjb border_table"
            style="border-bottom: none; border-top: none"
          >
            <el-table
              :span-method="objectSpanMethod4"
              border
              @cell-click="aqCellClick"
              :data="waqywdTabel"
              style="width: 100%"
            >
              <el-table-column
                prop="title"
                label=""
                width="100"
                align="center"
              />
              <el-table-column
                prop="type"
                label="类型"
                width="120"
                align="center"
              >
                <template #default="scope"> </template>
              </el-table-column>
              <el-table-column prop="content" label="情况描述">
                <template #default="scope"> </template>
              </el-table-column>
            </el-table>
          </div>
          <!-- 突发事件 重要会议级领导视察 -->
          <div
            class="jjb border_table"
            style="border-bottom: none; border-top: none"
          >
            <el-table
              @cell-click="tfCellClick"
              border
              :data="tfsjTabel"
              style="width: 100%"
            >
              <el-table-column
                prop="title"
                label=""
                width="100"
                align="center"
              />

              <el-table-column prop="content" label="情况描述">
                <template #default="scope"> </template>
              </el-table-column>
            </el-table>
          </div>
          <!-- 重要会议 -->
          <div
            class="jjb border_table"
            style="border-bottom: none; border-top: none"
          >
            <el-table
              @cell-click="zyhyCellClick"
              border
              :data="zyhyTabel"
              style="width: 100%"
            >
              <el-table-column
                prop="title"
                label=""
                width="100"
                align="center"
              />

              <el-table-column prop="content" label="情况描述">
                <template #default="scope"> </template>
              </el-table-column>
            </el-table>
          </div>
          <!-- 领导视察 -->
          <div
            class="jjb border_table"
            style="border-bottom: none; border-top: none"
          >
            <el-table
              @cell-click="ldscCellClick"
              border
              :data="ldscTabel"
              style="width: 100%"
            >
              <el-table-column
                prop="title"
                label=""
                width="100"
                align="center"
              />
              <el-table-column prop="content" label="情况描述">
                <template #default="scope"> </template>
              </el-table-column>
            </el-table>
          </div>
          <!-- 劳动备案情况 -->
          <div
            class="jjb border_table"
            style="border-bottom: none; border-top: none"
          >
            <el-table
              border
              :span-method="objectSpanMethod3"
              :data="ldbaTable"
              style="width: 100%"
                
            >
              <el-table-column
                prop="title"
                label=""
                width="100"
                align="center"
              />
              <el-table-column
                prop="colomm1"
                label=""
                align="center"
                width="200"
              >
                <template #default="scope">
                  <div :style="{ 'font-weight': getFontW(scope.row, '类别') }">
                    {{ scope.row.colomm1 }}
                  </div>
                </template>
              </el-table-column>

              <el-table-column
              align="center"
              v-for="(itz, idex) in jqName"
              :key="idex"
              :label="itz.name"
                
              >
                <template #default="scope">
                  <div  v-if="scope.$index == 0" @click="ldbaCellClick(getProp(scope, itz))">
                    {{ getProp(scope, itz) }}
                  </div>
                  <div v-else>
                      {{ getlable(scope, itz) }}
                  </div>
                </template>
              </el-table-column>
            </el-table>
          </div>
          <!-- 巡查记录 -->
          <div
            class="jjb border_table"
            style="border-bottom: none; border-top: none"
          >
            <el-table
              border
              @cell-click="xcCellClick"
              :span-method="objectSpanMethod2"
              :data="xcjlTable"
              style="width: 100%"
            >
              <el-table-column
                prop="title"
                label=""
                width="100"
                align="center"
              />

              <el-table-column
                prop="content"
                label="到岗履职"
                align="center"
                width="200"
              >
                <template #default="scope">
                  {{ scope.row.dglz }}
                </template>
              </el-table-column>
              <el-table-column
                prop="content"
                label="警容风纪"
                align="center"
                width="160"
              >
                <template #default="scope">
                  {{ scope.row.jrfz }}
                </template>
              </el-table-column>
              <el-table-column
                prop="content"
                label="警戒设置"
                align="center"
                width="200"
              >
                <template #default="scope">
                  {{ scope.row.jrsz }}
                </template>
              </el-table-column>
              <el-table-column
                prop="content"
                label="民警反应问题"
                align="center"
              >
                <template #default="scope">
                  {{ scope.row.mjfy }}
                </template>
              </el-table-column>
              <el-table-column
                prop="content"
                label="发现的其他问题"
                align="center"
              >
                <template #default="scope">
                  {{ scope.row.fxqt }}
                </template>
              </el-table-column>
            </el-table>
          </div>
          <!-- 重要会议 -->
          <div
            class="jjb border_table"
            style="border-bottom: none; border-top: none"
          >
            <el-table
              @cell-click="qtscCellClick"
              border
              :data="qtTabel"
              style="width: 100%"
            >
              <el-table-column
                prop="title"
                label=""
                width="100"
                align="center"
              />
              <el-table-column prop="content" label="情况描述">
                <template #default="scope"> </template>
              </el-table-column>
            </el-table>
          </div>
        </el-form>

        <div v-else>
          <mryqSave
            :listData="listData"
            :orgIds="orgIds"
            :types="types"
            :data="dataSon"
            @childEventSon="childEventSon"
            :account="account"
            :DailyLength="DailyLength"
            :DailyObj="DailyObj"
            :jqText="jqText"
          />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ElMessage } from "element-plus";
import http from "@/utils/api";
import mryqSave from "./mryqSave.vue";
import {
  Search,
  Share,
  Upload,
  TakeawayBox,
  Refresh,
  Collection,
  Plus,
  Loading,
  FolderDelete,
  Back,
} from "@element-plus/icons-vue";
import {
  ref,
  watch,
  onMounted,
  onBeforeUnmount,
  reactive,
  onBeforeMount,
  nextTick,
  onUnmounted,
} from "vue";
import { defineProps, defineEmits, computed } from "vue";

const value3 = ref("");
let zdryTable = ref([
  {
    title: "重要犯情",
    type: "重点人头",
    content: "",
  },
  {
    title: "重要犯情",
    type: "狱类案件",
    content: "",
  },
]);

let waqywdTabel = ref([
  {
    title: "五安全一稳定",
    type: "狱政类",
    content: "",
  },
  {
    title: "五安全一稳定",
    type: "环安类",
    content: "",
  },
  {
    title: "五安全一稳定",
    type: "网络舆情",
    content: "",
  },
  {
    title: "五安全一稳定",
    type: "医疗信息",
    content: "",
  },
  {
    title: "五安全一稳定",
    type: "生产类",
    content: "",
  },
]);
let tfsjTabel = ref([
  {
    title: "突发事件",
    content: "",
  },
]);

let zyhyTabel = ref([
  {
    title: "重要会议",
    content: "",
  },
]);
let ldscTabel = ref([
  {
    title: "领导视察",
    content: "",
  },
]);
let qtTabel =ref([
{
    title: "其他",
    content: "",
  },
])
let xcjlTable = ref([
  {
    title: "巡查记录",
    dglz: "到岗履职",
    jrfz: "警容风纪",
    jrsz: "警戒设置",
    mjfy: "民警反应问题",
    fxqt: "发现的其他问题",
  },
  {
    title: "巡查记录",
    dglz: "",
    jrfz: "",
    jrsz: "",
    mjfy: "",
    fxqt: "",
  },
]);

let tableDatas = ref([
  {
    jq: "",
    name: "--",
    syfr: "--",
    tpfr: "--",
    zcfr: "--",
    zyfr: "--",
    jbfr: "--",
    cjxd: "--",
    jnzy: "--",
    jrxm: "--",
    jwzx: "--",
    jwzy: "--",
    ljtq: "--",
    jl: "--",
    ldfr: "--",
  },
]);

let ldbaTable = ref([
  {
    title: "劳动备案情况",
    colomm1: "类别",
  },
  {
    title: "劳动备案情况",
    colomm1: "A类加班",
  },
  {
    title: "劳动备案情况",
    colomm1: "B类补丁额",
  },
  {
    title: "劳动备案情况",
    colomm1: "C类自愿申请劳动",
  },
]);

//其他
const getFontW = (row, text) => {
  if (row.colomm1 == text) {
    // console.log(row, "[[[]]]");
    return "bold";
  } else {
    return "normal";
  }
};

let types = ref("");
let dataSon = ref({});
const props = defineProps({
  orgIds: {
    type: Number,
    default: 22,
  },
  pids: {
    type: Number,
    default: 173,
  },
  orgName: {
    type: String,
    default: "",
  },
  jqArr: {
    type: Array,
    default: [],
  },
});

const childEventSon = (data) => {
  isShows.value = true;
  getShiftLogSelect();
};

const zyhyCellClick = (row, clomm) => {
  if( dayStr.value != daydata.value)return
  if (clomm.property == "title") {
    dataSon.value = row;
    types.value = "重要会议";
    isShows.value = false;
  }
};
const qtscCellClick = (row, clomm) => {
  if( dayStr.value != daydata.value)return
  if (clomm.property == "title") {
    dataSon.value = row;
    types.value = "其他";
    isShows.value = false;
  }
};
const ldscCellClick = (row, clomm) => {
  if (clomm.property == "title") {
    dataSon.value = row;
    types.value = "领导视察";
    isShows.value = false;
  }
};

const zbCellClick = (row, clomm) => {
   console.log(row,']]]');
   
  if( dayStr.value != daydata.value)return
  if (clomm.property == "date") {
    dataSon.value = row;
    types.value = "值班";
    isShows.value = false;
  }
};
const zyCellClick = (row, clomm) => {
  if( dayStr.value != daydata.value)return
  if (clomm.property == "title") {
    dataSon.value = row;
    types.value = "重要";
    isShows.value = false;
  }
};
const tfCellClick = (row, clomm) => {
  if( dayStr.value != daydata.value)return
  if (clomm.property == "title") {
    dataSon.value = row;
    types.value = "突发";
    isShows.value = false;
  }
};
const aqCellClick = (row, clomm) => {
  if( dayStr.value != daydata.value)return
  if (clomm.property == "title") {
    dataSon.value = row;
    types.value = "安全";
    isShows.value = false;
  }
};
const yqCellClick = (row, clomm) => {
  if( dayStr.value != daydata.value)return
  if (clomm.property == "title") {
    dataSon.value = row;
    types.value = "狱情";
    isShows.value = false;
  }
};
const xcCellClick = (row, clomm) => {
  if( dayStr.value != daydata.value)return
  if (clomm.property == "title") {
    dataSon.value = row;
    types.value = "巡查";
    isShows.value = false;
  }
};
let jqText = ref('')
const ldbaCellClick = (row, clomm) => {
  if( dayStr.value != daydata.value)return
  if (row) {
    jqText.value = row;
    types.value = "监区";
    isShows.value = false;
  }
};

const objectSpanMethod5 = ({ row, column, rowIndex, columnIndex }) => {
  if (columnIndex === 0) {
    if (rowIndex == 0) {
      return {
        rowspan: 2,
        colspan: 1,
      };
    } else {
      return {
        rowspan: 0,
        colspan: 0,
      };
    }
  }
};
const objectSpanMethod4 = ({ row, column, rowIndex, columnIndex }) => {
  if (columnIndex === 0) {
    if (rowIndex == 0) {
      return {
        rowspan: 5,
        colspan: 1,
      };
    } else {
      return {
        rowspan: 0,
        colspan: 0,
      };
    }
  }
};

const objectSpanMethod = ({ row, column, rowIndex, columnIndex }) => {
  if (columnIndex == 1) {
    if (rowIndex == 1) {
      return {
        rowspan: 1,
        colspan: 5,
      };
    }
  }
  if (
    columnIndex == 4 ||
    columnIndex == 3 ||
    columnIndex == 2 ||
    columnIndex == 5
  ) {
    if (rowIndex == 1) {
      return {
        rowspan: 0,
        colspan: 0,
      };
    }
  }
};

/**
       *
       * @param param0 return {rowspan: 1,colspan: 1 } 表示表格不变
      return {rowspan: 2,colspan: 1 } 表示表格向下合并一个单元格
      return {rowspan: 1,colspan: 2 } 表示表格向右合并一个单元格
      return {rowspan: 0,colspan: 0 } 表示删除此单元格
    row: 当前行的数据对象。
column: 当前列的数据对象。
rowIndex: 当前行的索引。
columnIndex: 当前列的索引。
       */

const objectSpanMethod3 = ({ row, column, rowIndex, columnIndex }) => {
  if (columnIndex === 0) {
    if (rowIndex == 0) {
      return {
        rowspan: 4,
        colspan: 1,
      };
    } else {
      return {
        rowspan: 0,
        colspan: 0,
      };
    }
  }
};
const objectSpanMethod2 = ({ row, column, rowIndex, columnIndex }) => {
  if (columnIndex === 0) {
    if (rowIndex % 2 === 0) {
      return {
        rowspan: 2,
        colspan: 1,
      };
    } else {
      return {
        rowspan: 0,
        colspan: 0,
      };
    }
  }
};
const objectSpanMethodCv = ({ row, column, rowIndex, columnIndex }) => {
  if (columnIndex === 0) {
    if (rowIndex == 0) {
      return {
        rowspan: 5,
        colspan: 1,
      };
    } else {
      return {
        rowspan: 0,
        colspan: 0,
      };
    }
  }
};
const emit = defineEmits(["childEvent"]);
const tableDataZb = ref([
  {
    date: "总值班长",
    name: "领导",
    a: "",
    names: "值班主任",

    b: "",
    c: "日期",
    d: "",
  },
  {
    date: "值班民警",
    name: "领导",
    a: "",
    names: "民警",
    d: "",
    b: "",
    c: "罪犯人数",
  },
]);
let formDataJJB = ref({});
onBeforeMount(() => {});
let dateSfm = ref("");
let hour = ref("");
let daydata = ref("");
let years = ref("");
let months = ref("");
// 获取年月日 时
const getFormattedDateTime = () => {
  const now = new Date();
  const year = now.getFullYear();
  const month = String(now.getMonth() + 1).padStart(2, "0");
  const day = String(now.getDate()).padStart(2, "0");
  const hours = String(now.getHours()).padStart(2, "0");
  const minutes = String(now.getMinutes()).padStart(2, "0");
  const seconds = String(now.getSeconds()).padStart(2, "0");
  dateSfm.value = `${hours}:${minutes}:${seconds}`;
  hour.value = String(now.getHours()).padStart(2, "0");
  daydata.value = `${year}-${month}-${day}`;
  years.value = `${year}`;
  months.value = `${month}`;
  return `${year}-${month}-${day} ${hour.value}`;
};

let yqList = ref([
  {
    title: "狱情信息",

    content: "",
  },
]);

const selectValue = ref("");

let dateArr = ref([]);

let formattedDateStr = ref("");
let formattedNextDateStr = ref("");

const getTimeRangeFun = async (dateString) => {
  // const date = new Date(dateString);
  // const year = date.getFullYear();
  // const month = String(date.getMonth() + 1).padStart(2, "0"); // 月份从0开始，所以需要+1
  // const day = String(date.getDate()).padStart(2, "0");

  // // 格式化日期为 YYYY-MM-DD
  // const formattedDate = `${year}-${month}-${day}`;

  // // 创建第二天的日期对象
  // const nextDay = new Date(date);
  // nextDay.setDate(nextDay.getDate() + 1);
  // const nextYear = nextDay.getFullYear();
  // const nextMonth = String(nextDay.getMonth() + 1).padStart(2, "0");
  // const nextDayStr = String(nextDay.getDate()).padStart(2, "0");

  // // 格式化第二天的日期为 YYYY-MM-DD
  // const formattedNextDate = `${nextYear}-${nextMonth}-${nextDayStr}`;

  // // 返回时间段字符串
  // formattedDateStr.value = formattedDate;
  // formattedNextDateStr.value = formattedNextDate;

  getShiftLogSelect();
};
const getShiftLogSelect = async () => {

  //整点情况
  // getZtFun();
  //要情情况
  getZhzxDailySelect();
};
let DailyLength = ref([]);
let DailyObj = ref({});
let tsArr = ref([])
const getZhzxDailySelect = async () => {
  let res = await http.znjw.ZhzxDailySelect({
    page: 1,
    limit: 200,
    orgId: "",
    date: dayStr.value,
  });
  if (res && res.code == 0) {
    DailyLength.value = res.data.total;
    DailyObj.value = res.data.data[0] || {};



getZdbSelect()




    tableDataZb.value[0].a = DailyObj.value.zzbz;
    tableDataZb.value[0].b = DailyObj.value.zbzr;
    tableDataZb.value[1].a = DailyObj.value.zbmj;

    //  狱情
    tableDatas.value[0].zcfr = DailyObj.value.yqzc;
    tableDatas.value[0].zyfr = DailyObj.value.yqzy;
    tableDatas.value[0].syfr = DailyObj.value.yqsy;
    tableDatas.value[0].jnzy = DailyObj.value.yqyw;
    tableDatas.value[0].ljtq = DailyObj.value.yqlj;
    tableDatas.value[0].jbfr = DailyObj.value.yqbf;
    tableDatas.value[0].cjxd = DailyObj.value.yqzx;
    tableDatas.value[0].jwzy = DailyObj.value.yqbz;
    tableDatas.value[0].jwzx = DailyObj.value.yqzs;
    tableDatas.value[0].tpfr = DailyObj.value.yqtp;

    //重要犯情
    zdryTable.value[0].content = DailyObj.value.zyzdry;
    zdryTable.value[1].content = DailyObj.value.zyylaj;

    //安全
    waqywdTabel.value[0].content = DailyObj.value.aqyz;
    waqywdTabel.value[1].content = DailyObj.value.aqha;
    waqywdTabel.value[2].content = DailyObj.value.aqwl;
    waqywdTabel.value[3].content = DailyObj.value.aqyl;
    waqywdTabel.value[4].content = DailyObj.value.aqsc;

    //突发
    tfsjTabel.value[0].content = DailyObj.value.tfsj;
    zyhyTabel.value[0].content = DailyObj.value.zyhy;
    ldscTabel.value[0].content = DailyObj.value.ldsc;

    //
    xcjlTable.value[1].dglz = DailyObj.value.xcdg;
    xcjlTable.value[1].jrfz = DailyObj.value.xcjr;
    xcjlTable.value[1].jrsz = DailyObj.value.xcjj;
    xcjlTable.value[1].mjfy = DailyObj.value.xcmj;
    xcjlTable.value[1].fxqt = DailyObj.value.xcqt;


    //备案
    if(DailyObj.value?.ldba){

      tsArr.value = JSON.parse(DailyObj.value.ldba)
    }

    //其他
    qtTabel.value[0].content = DailyObj.value.qt
  
  }
};

const getZdbSelect = async()=>{

  let resZb = await http.znjw.ZdbSelect({
    type: "zhzx",
    zbType: "1",
    orgId: 44 || "",
    shift: "",
    account: "",
    date: dayStr.value,
  });
if(resZb && resZb.code == 0){

  tableDataZb.value[1].a = ''
if( resZb.data.length){
  resZb.data.forEach((item)=>{
    if(item.zbry){

      tableDataZb.value[1].a +=','+item.zbry;
    }
  })

  if( tableDataZb.value[1].a){
    DailyObj.value.zbmj = ''
    tableDataZb.value[1].a =  tableDataZb.value[1].a.split(',').slice(1).join(',');
    DailyObj.value.zbmj =  tableDataZb.value[1].a.split(',').slice(1).join(',');
  }
}
  // tableDataZb.value[1].a +=','+ DailyObj.value.zbmj;
   console.log(resZb.data,'[[[[]]]]');
   
}

}

let dayStr = ref("");
const itemClick = (index, item) => {
  dateArr.value.forEach((item) => {
    item.is = false;
  });

  dayStr.value = item.date;
  tableDataZb.value[0].d = item.date
  getShiftLogSelect();
  dateArr.value[index].is = true;
};

let zdzfTabel = ref([]);

const chanse = (row) => {
  if (row) {
    years.value = `${row.split("-")[0]}`;
    months.value = `${row.split("-")[1]}`;
    getMonthDates();
  } else {
  }
};

const getMonthDates = () => {
  const now = new Date();
  const year = Number(years.value);
  console.log();

  const month = Number(months.value); // 注意：月份从0开始，所以11表示12月
  // 获取当前月的天数
  const daysInMonth = new Date(year, month, 0).getDate();
  // 生成日期数组
  const dates = [];
  for (let day = 1; day <= daysInMonth; day++) {
    const dateString = `${year}-${String(month).padStart(2, "0")}-${String(
      day
    ).padStart(2, "0")}`;
    dates.push({
      date: dateString,
      is: false,
    });
  }
  console.log(dates, "99++9+9");

  dateArr.value = dates;
  dateArr.value.forEach((item) => {
    if (item.date == daydata.value) {
      item.is = true;
    }
  });
  //   return dates;
};

let listData = ref([]);
let jcNub = ref(0);
let peopleArr = ref([]);


let isShows = ref(true);
let sonBigArr = ref([]);
const getZtFun = async () => {
  let res = await http.zfpt.ClockLast({
    // orgId:'22',
    orgId: selectValue.value,
    date: daydata.value,
    hour: hour.value,
    async: "",
  });
  if (res && res.code == 0) {
    sonBigArr.value = res.data;
    if (sonBigArr.value.length) {
      sonBigArr.value.forEach((item) => {
        if (Number(item.hour.split(":")[0]) == hour.value) {
          tableDatas.value.forEach((iot) => {
            for (let key in iot) {
              if (item[key]) {
                iot[key] = item[key];
              }
            }
          });
        }
      });
    } else {
      tableDatas.value = [
        {
          jq: "",
          name: "--",
          syfr: "--",
          tpfr: "--",
          zcfr: "--",
          zyfr: "--",
          jbfr: "--",
          cjxd: "--",
          jnzy: "--",
          jrxm: "--",
          jwzx: "--",
          jwzy: "--",
          ljtq: "--",
          jl: "--",
          ldfr: "--",
        },
      ];
    }
  }
};
let jqName = ref([]);
let getProp = (row, itz) => {
  let obj = row.row;
  let text = "";
  for (let key in obj) {
    if (obj[key]) {
      if (obj[key] == itz.name) {
        text = obj[key];
      }
    }
  }

  return text;
};
let getlable = (row, itz) => {
  let str = ''

  tsArr.value.forEach((item)=>{
     if(item.name == row.column.label){
       if(row.$index == 1){
        str = item.jb
       }
       if(row.$index == 2){
        str = item.bd
       }
       if(row.$index == 3){
        str = item.ld
       }
     }
  })
    
return str
};
watch(
  () => props.jqArr,
  (newValue, oldValue) => {
    jqName.value = JSON.parse(sessionStorage.getItem("jqArr")).filter((item) =>
      item.name.includes("监区")
    );
    ldbaTable.value.forEach((item, index) => {
      jqName.value.forEach((itz, ind) => {
        if (index == 0) {
          item[`row${ind + 1}`] = itz.name;
        } else {
          item[`row${ind + 1}`] = "";
        }
      });
    });
   
    getFormattedDateTime();
    value3.value = daydata.value;
    dayStr.value = daydata.value;
    tableDataZb.value[0].d =  value3.value
    if (newValue) {
      getMonthDates();
      getTimeRangeFun(daydata.value);
    }
  },
  {
    deep: true, // 深度监听
    immediate: true, // 立即触发回调
  }
);
</script>

<style scoped lang="scss">
.month_box {
  width: 100%;
  height: 94%;
  overflow-y: scroll;
  margin-top: 4px;
  .items {
    font-size: 14px;
    width: 100%;
    margin-bottom: 4px;
    cursor: pointer;
    height: 24px;
    color: #fff;
    border-bottom: 1px solid rgba(15, 82, 163, 0.61);
    // background-color: #e9e9e979;
  }
}

::v-deep .colmm_table {
  .el-table__header-wrapper {
    display: none !important;
  }
  .el-scrollbar__view {
    width: 100%;
  }
}

::v-deep .jjb {
  .el-table td.el-table__cell div {
    min-height: 30px;
  }
  .el-table td.el-table__cell .colmm_table {
    height: 100px;
    overflow-y: scroll;
    padding-top: 15px;
  }

  .el-table__header-wrapper {
    display: none !important;
  }
  .el-scrollbar__view {
    width: 100%;
  }
  .table_top {
    height: 30px !important;
    width: 100%;
    // border: 1px solid red;
    display: flex;
    align-items: center;
    border: 1px solid rgb(5, 112, 146);
    // border-bottom: none;
    div {
      display: flex;
      align-items: center;
      justify-content: center;
      height: 100% !important;
      border-right: 1px solid rgb(5, 112, 146);
      width: 122px;
    }
  }
}

::v-deep .el-form {
  margin-top: 16px;
}
::v-deep .date_searchbox {
  .el-input__wrapper {
    background-color: rgba(15, 82, 163, 0.278);
    box-shadow: (0 0 0 1px rgba(15, 82, 163, 0.61)) inset;
  }
  .el-input__inner {
    color: white;
  }
  .el-input__prefix {
    color: white;
  }
}
.isDate {
  color: #ffffff;
  font-weight: bold;
  border-color: rgb(18, 123, 215) !important;
  // background-color: #e9e9e9ea !important;
}
.date_searchbox {
  width: 220px;
  height: 99%;
  // border: 1px solid red;
  margin-right: 6px;
}
.month_box {
  width: 100%;
  height: 96%;
  overflow-y: scroll;
  margin-top: 4px;
  .items {
    font-size: 14px;
    width: 100%;
    margin-bottom: 4px;
    cursor: pointer;
    height: 24px;
    color: #fff;
    border-bottom: 1px solid rgba(15, 82, 163, 0.61);
    // background-color: #e9e9e979;
  }
}
.border_table {
  border: 1px solid rgba(15, 82, 163, 0.61);
  border-right: none;
}

.jjb_text {
  position: absolute;
  left: 60%;
  transform: translate(-50%, -50%);
  top: 144px;
  font-size: 16px;
  font-weight: bold;
  color: white;
}
.date_box {
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 14px;
  padding-right: 64px;
  font-size: 14px;
  color: #e5dfdf;
}

.wrap_text {
  width: 60px;
  overflow-wrap: break-word; /* 新版浏览器支持 */
}
.yc_table {
  width: 100%;
  overflow-y: scroll;
  color: white;
  // height: 66px;
  height: 200px;
  .table_item {
    width: 100%;
    height: 30px;
    cursor: pointer;
    height: 25px;
    justify-content: space-evenly;
    font-size: 12px;
  }
}
.jj_box {
  margin-bottom: 0px;
  font-size: 14px;
}
.drawer_box {
  width: 100%;
  height: 780px;

  display: flex;
  position: relative;
  .dialog-footer {
    position: absolute;
    bottom: -50px;
    right: 2px;
    // font-size: 18px;
  }
}
</style>
